/**
 * @param {number[]} nums
 * @return {number}
 */
 var countMaxOrSubsets = function(nums) {
  const n = nums.length
  let max = -Infinity
  const dfs = (now, idx) => {
      max = Math.max(max, now)
      for(let i = idx; i<n; i++){
          dfs(now | nums[i], i+1)
      }
  }
  dfs(0, 0)
  let ans = 0
  const findAns = (now, idx) => {
      if(now === max) ans++
      for(let i = idx; i<n; i++){
          findAns(now | nums[i], i+1)
      }
  }
  findAns(0, 0)
  return ans
};